<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>登录页面</h1>
    <span>邮箱</span><input id="email" type="text"></br>
    <span>密码</span><input id="password" type="text"></br></br>
    <input type="button" value="登录" onclick="login()"/></br></br>

    <a style="color: blue;" onclick="goRegist()">注册</a></br></br></br>

    <input type="button" value="获取登录INFO(测试统一认证拦截)" onclick="loginInfo()"/></br>



<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
<script type="text/javascript">

function login() {
    var email = $("#email").val();
    var password = $("#password").val();
    var url = "http://127.0.0.1:9002/user/login/"+email+"/"+password;

    $.ajax({
        url: url,
        type: 'post',
        async:false,
        dataType : "text",
        data:{

        },
        timeout:5000,
        success:function (data) {
            if(data=="true"){
                var newUrl = "./welcome.html";
                $(window).attr('location',newUrl);
            }else{
                alert("登录失败");
                return;
            }
        },
    })
}


function goRegist(){
    var newUrl = "./register.html";
    $(window).attr('location',newUrl);
}

function loginInfo() {
    var url = "http://127.0.0.1:9002/user/info";

    $.ajax({
        url: url,
        type: 'post',
        async:false,
        dataType : "text",
        data:{

        },
        timeout:5000,
        success:function (data) {
            alert(data)
        },
        error:function(xhr,state,errorThrown){
            alert(xhr.responseText);
        }
    })
}




</script>
</body>
</html>